/**
 * Copyright (c) 2018 软唐 All rights reserved.
 *
 * https://www.softtown.cn
 *
 * 版权所有，侵权必究！
 */

package com.softtown.modules.dapai.controller;

import com.github.pagehelper.PageInfo;
import com.softtown.common.utils.Result;
import com.softtown.modules.dapai.dto.CompLeaseManagePageDTO;
import com.softtown.modules.dapai.dto.CompLeaseOrderPageDTO;
import com.softtown.modules.dapai.dto.LeaseManageAddOrUpdateDTO;
import com.softtown.modules.dapai.dto.LeaseOrderAddOrUpdateDTO;
import com.softtown.modules.dapai.entity.CompLeaseManageEntity;
import com.softtown.modules.dapai.entity.CompLeaseOrderEntity;
import com.softtown.modules.dapai.service.CompLeaseManageService;
import com.softtown.modules.dapai.service.CompLeaseOrderService;
import com.softtown.modules.dapai.vo.CompLeaseManageVO;
import com.softtown.modules.dapai.vo.CompLeaseOrderVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 租赁订单管理
 *
 * @author Ding Ya Yong
 */
@RestController
@RequestMapping("leaseManage")
@Api(tags="租赁订单管理")
public class CompLeaseManageController {

    @Resource
    private CompLeaseManageService compLeaseManageService;


    @PostMapping("getLeaseManagePageList")
    @ApiOperation("获取租赁订单管理分页")
    public Result getLeaseManagePageList(@RequestBody CompLeaseManagePageDTO compLeaseManagePageDTO) {
        PageInfo<CompLeaseManageEntity> compLeaseManageEntityPageInfo = compLeaseManageService.getLeaseManagePageList(compLeaseManagePageDTO);
        return new Result<PageInfo<CompLeaseManageEntity>>().ok(compLeaseManageEntityPageInfo);
    }





    @PostMapping("getLeaseManageById")
    @ApiOperation("获取租赁订单详情")
    public Result<CompLeaseManageVO> getLeaseManageById(@RequestBody CompLeaseManagePageDTO compLeaseManagePageDTO) {
        CompLeaseManageVO compLeaseManageVO = compLeaseManageService.getLeaseManageById(compLeaseManagePageDTO.getCompId(),compLeaseManagePageDTO.getId());
        return new Result<CompLeaseManageVO>().ok(compLeaseManageVO);
    }


    @PostMapping("addLeaseManage")
    @ApiOperation("添加租赁订单")
    public Result addLeaseManage(@RequestBody LeaseManageAddOrUpdateDTO leaseManageAddOrUpdateDTO) {
        Result result = new Result<>();
        compLeaseManageService.addLeaseManage(leaseManageAddOrUpdateDTO);
        return result;
    }


    @PostMapping("updateLeaseManage")
    @ApiOperation("编辑租赁订单")
    public Result updateLeaseManage(@RequestBody LeaseManageAddOrUpdateDTO leaseManageAddOrUpdateDTO) {
        Result result = new Result<>();
        compLeaseManageService.updateLeaseManage(leaseManageAddOrUpdateDTO);
        return result;
    }



    @PostMapping("deleteLeaseManage")
    @ApiOperation("删除租赁订单")
    public Result deleteLeaseManage(@RequestBody CompLeaseManagePageDTO compLeaseManagePageDTO) {
        Result result = new Result<>();
        compLeaseManageService.deleteLeaseManage(compLeaseManagePageDTO.getCompId(),compLeaseManagePageDTO.getId());
        return result;
    }




}